/*
* Copyright (c) 2020 The canvas Authors. All rights reserved.
  Use of this source code is governed by a BSD-style license that can be
  found in the LICENSE file.

* Author:         dzlua - https://gitee.com/dzlua/canvas.git
* Email:          505544956@qq.com
* FileName:       canvas_2d_impl.h
* Create Time:    2020/02/13 19:19:37
* Description:    /
*/

#ifndef __CANVAS_2D_IMPL_H__
#define __CANVAS_2D_IMPL_H__

#include <canvas_2d.h>

namespace cvs {
namespace c2d {
  class CVS_API Shape : virtual public IShape {
    public:
      virtual ShapeType type() const override;
    protected:
      Shape(ShapeType type);
      virtual ~Shape();
    protected:
      ShapeType type_;
  };
  class CVS_API ShapeLine : public Shape, virtual public IShapeLine {
    public:
      virtual Result reset() override;
      virtual Result set(const Point &pt1, const Point &pt2) override;
      virtual Point point1() const override;
      virtual Point point2() const override;
    protected:
      ShapeLine();
      virtual ~ShapeLine();
    protected:
      Point pt1_, pt2_;
  };
  class CVS_API ShapePolyline : public Shape, virtual public IShapePolyline {
    public:
      virtual Result reset() override;
      virtual Result set(const Point *pts, uint count) override;
      virtual Point* points() const override;
      virtual uint count() const override;
    protected:
      ShapePolyline();
      virtual ~ShapePolyline();
    protected:
      Point *points_;
      uint count_;
  };
  class CVS_API ShapeBezier : public Shape, virtual public IShapeBezier {
    public:
      virtual Result reset() override;
      virtual Result set(const BezierSegment &beizer) override;
      virtual Result set(const Point &pt0, const Point &pt1, const Point &pt2, const Point &pt3) override;
      virtual Point point0() const override;
      virtual Point point1() const override;
      virtual Point point2() const override;
      virtual Point point3() const override;
    protected:
      ShapeBezier();
      virtual ~ShapeBezier();
    protected:
      Point pt0_, pt1_, pt2_, pt3_;
  };
  class CVS_API ShapeArc : public Shape, virtual public IShapeArc {
    public:
      virtual Result reset() override;
      virtual Result set(const ArcSegment &arc) override;
      virtual Result set(const Point &start, const Point &end, const Size &size, dtype angle, bool sweep, bool large) override;
      virtual Point start() const override;
      virtual Point end() const override;
      virtual Size size() const override;
      virtual dtype angle() const override;
      virtual bool sweep() const override;
      virtual bool large() const override;
    protected:
      ShapeArc();
      virtual ~ShapeArc();
    protected:
      Point start_, end_;
      Size size_;
      dtype angle_;
      bool sweep_;
      bool large_;
  };
  class CVS_API ShapePolygon : public Shape, virtual public IShapePolygon {
    public:
      virtual Result reset() override;
      virtual Result set(const Point *pts, uint count) override;
      virtual Point* points() const override;
      virtual uint count() const override;
    protected:
      ShapePolygon();
      virtual ~ShapePolygon();
    protected:
      Point *points_;
      uint count_;
  };
  class CVS_API ShapeRect : public Shape, virtual public IShapeRect {
    public:
      virtual Result reset() override;
      virtual Result set(const Rect &rect, const Size &radius) override;
      virtual Rect rect() const override;
      virtual Size radius() const override;
    protected:
      ShapeRect();
      virtual ~ShapeRect();
    protected:
      Rect rect_;
      Size radius_;
  };
  class CVS_API ShapeCircle : public Shape, virtual public IShapeCircle {
    public:
      virtual Result reset() override;
      virtual Result set(const Point &center, dtype radius) override;
      virtual Point center() const override;
      virtual dtype radius() const override;
    protected:
      ShapeCircle();
      virtual ~ShapeCircle();
    protected:
      Point center_;
      dtype radius_;
  };
  class CVS_API ShapeEllipse : public Shape, virtual public IShapeEllipse {
    public:
      virtual Result reset() override;
      virtual Result set(const Point &center, const Size &radius) override;
      virtual Point center() const override;
      virtual Size radius() const override;
    protected:
      ShapeEllipse();
      virtual ~ShapeEllipse();
    protected:
      Point center_;
      Size radius_;
  };
  class CVS_API ShapePath : public Shape, virtual public IShapePath {
    protected:
      ShapePath();
      virtual ~ShapePath();
  };
  class CVS_API ShapeText : public Shape, virtual public IShapeText {
    public:
      virtual Result reset() override;
      virtual Result set(const wchar_t *text, uint len, const Rect &rect
          , const FontFormat &font, const TextFormat &format) override;
      //
      virtual Rect rect() const override;
      //
      virtual const wchar_t* font_family() const override;
      virtual Result set_font_family(const wchar_t *family) override;
      virtual dtype font_size() const override;
      virtual Result set_font_size(dtype size) override;
      virtual bool font_italic() const override;
      virtual Result set_font_italic(bool italic) override;
      virtual bool font_bold() const override;
      virtual Result set_font_bold(bool bold) override;
      virtual bool font_strikethrough() const override;
      virtual Result set_font_strikethrough(bool strikethrough) override;
      virtual bool font_underline() const override;
      virtual Result set_font_underline(bool underline) override;
      //
      virtual TextAlignHor text_hor_align() const override;
      virtual Result set_text_hor_align(const TextAlignHor align) override;
      virtual TextAlignVer text_ver_align() const override;
      virtual Result set_text_ver_align(const TextAlignVer align) override;
      virtual TextDirection text_direction() const override;
      virtual Result set_text_direction(const TextDirection direction) override;
      virtual bool text_word_warp() const override;
      virtual Result set_text_word_warp(bool word_wrap) override;
    protected:
      ShapeText();
      virtual ~ShapeText  ();
    protected:
      const wchar_t *text_;
      uint len_;
      Rect rect_;
      FontFormat font_;
      TextFormat format_;
  };
} // end namespace c2d
} // end namespace cvs

#endif // __CANVAS_2D_IMPL_H__